<?php
/**
 * FileName: SystemSettingBasicForm.php
 * Author: 790213952@qq.com
 * DateTime: 2024/8/7 下午12:34
 * SystemName: Ymtc
 *
 */


/**
 * FileName: SiteConfig.php
 * Author: Xiao Yao <790213952@qq.com>
 * DateTime: 2022-09-15 下午 02:23
 * Summary:
 */


namespace YmPhp\Admin\Http\Forms;


use YmPhp\Admin\Models\Setting as SystemSettingModel;
use YmPhp\Admin\Widgets\Form;
use Illuminate\Http\Request;

class SystemSettingModerationForm extends Form
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = '基本设置';

    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     */
    public function handle(array $input)
    {
        (new SystemSettingModel())->saveConfig($input,'system_moderation');
        return $this->response()->success('保存成功')->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {

        $this->tab(trans('setting.moderation.moderation_settings'), function () {
            $this->text('accesskey_id', trans('setting.basic.accessKeyID'));
            $this->text('accesskey_Secret', trans('setting.basic.accessKeySecret'));
            $this->text('moderation_endpoint', trans('setting.moderation.moderation_endpoint'))->help(trans('setting.moderation.moderation_endpoint_msg'));
            $this->radio('ali_open_txt', trans('setting.moderation.ali_open_txt'))->options(['0'=>trans('setting.basic.close'),'1'=>trans('setting.basic.open')])->help(trans('setting.moderation.ali_open_txt_msg'));
            $this->radio('ali_open_img', trans('setting.moderation.ali_open_img'))->options(['0'=>trans('setting.basic.close'),'1'=>trans('setting.basic.open')])->help(trans('setting.moderation.ali_open_img_msg'));
        });
    }

    /**
     * The data of the form.
     *
     * @return array $data
     */
    public function data()
    {
        $datas = SystemSettingModel::pluck('value', 'key');
        return $datas['system_moderation'];
    }


}

